<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入css样式 -->
    <link rel="stylesheet" href="./css/index.css">
    <title>记事本</title>
</head>

<body>

    <body>
        <!-- 主体区域 -->
        <section id="box">
            <!-- 输入框 -->
            <header class="header">
                <h1>阿闷的记事本</h1>
                <input type="text" class="text" v-model="inputValue" @keyup.enter="add">
            </header>
            <!-- 列表区域 -->
            <section class="list">
                <ul class="list_hd">
                    <li class="list_bd" v-for="(item,index) in list">
                        <div>
                            <label>{{index+1}}.</label>
                            <span>{{item}}</span>
                            <a href="javascript:;" class="delete" @click="remove">x</a>
                        </div>

                    </li>
                    <span class="list_ft" v-if="list.length!=0">
                        {{list.length}}条代办
                        <button class="clear" @click="clear">clear</button>
                    </span>
                </ul>
            </section>
            <!-- 统计和清空 -->
            <footer class="footer">

            </footer>
            <!-- 底部 -->
            <footer class="info">
                <a href="#">
                    <span class="happy1">
                        键盘敲烂 !
                    </span>
                </a>
                <img src="images/lb4.jpg" alt="">
                <a href="#">
                    <span class="happy2">
                        月入过万 !
                    </span>
                </a>
                <h4>写代码是一件非常快乐的事情 ！</h4>
            </footer>
        </section>
        <!-- 引入vue -->
        
        <script src="https://cdn.jsdelivr.net/npm/vue@2.6.12"></script>

        <script>
            // 1.生成列表结构：(v-for 数组)
            // 2.获取用户输入(v-model)
            // 3.回车，新增数据(v-on.enter 添加数据)
            var app = new Vue({
                el: "#box",
                data: {
                    list: ['吃饭', '睡觉', '打豆豆'],
                    inputValue: "起床写代码啦 !",
                },
                methods: {
                    add: function () {
                        this.list.push(this.inputValue);
                    },
                    remove: function (index) {
                        this.list.splice(index, 1);
                    },
                    clear: function () {
                        this.list = [];
                    }
                }
            })
        </script>
    </body>

</html>